package com.airline.connection;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;

import com.airline.beans.Customer;
import com.airline.beans.Employee;
import com.airline.beans.Flight;
import com.airline.beans.Journey;

public class TestClass {

	public static AirlineSystemService airlineservice = new AirlineSystemService();
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		System.out.println("Testing..");
		

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		
//		//***TEST EMPLOYEE LOGIN***
//		try {
//			System.out.println("Testing Employee Login...");
//			System.out.println("Enter a username:");
//			String username = br.readLine();
//			System.out.println("Enter a password:");
//			String password = br.readLine();
//			
//			System.out.println("Test only providing username: employeeLogin(username, null)");
//			System.out.println("Result= " + airlineservice.employeeLogin(username, null));
//			System.out.println("Test only providing password: employeeLogin(null, password)");
//			System.out.println("Result= " + airlineservice.employeeLogin(null, password));
//			System.out.println("Test providing both username and password: employeeLogin(username, password)");
//			Employee employee = airlineservice.employeeLogin(username, password);
//			if (employee == null) {
//				System.out.println("Result= Provided credentials not valid.");
//			} else {
//				System.out.println("Result= Provided credentials valid.");
//			}
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//		//***TEST CUSTOMER LOGIN***
//		try {
//			System.out.println("Testing Customer Login...");
//			System.out.println("Enter a username:");
//			String username = br.readLine();
//			System.out.println("Enter a password:");
//			String password = br.readLine();
//			
//			System.out.println("Test only providing username: employeeLogin(username, null)");
//			System.out.println("Result= " + airlineservice.customerLogin(username, null));
//			System.out.println("Test only providing password: employeeLogin(null, password)");
//			System.out.println("Result= " + airlineservice.customerLogin(null, password));
//			System.out.println("Test providing both username and password: employeeLogin(username, password)");
//			Customer customer = airlineservice.customerLogin(username, password);
//			if (customer == null) {
//				System.out.println("Result= Provided credentials not valid.");
//			} else {
//				System.out.println("Result= Provided credentials valid.");
//			}
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}

		//***TEST CREATE EMPLOYEE***
//		try {
			System.out.println("Testing Employee Creation...");
//			System.out.println("Enter a first name:");
//			String firstName = br.readLine();
//			System.out.println("Enter a last name:");
//			String lastName = br.readLine();
//			System.out.println("Enter a work position:");
//			String workPosition = br.readLine();
			
//			System.out.println("Test creating new employee from data: createEmployee(Employee e)");
//			String result = airlineservice.createEmployee(new Employee("","ProvidedPassword","hello","lastName","Address","City","State","Zip","Date","WorkDesc","workPosition","HireDate"));
//			System.out.println("Result= " + result);
//			System.out.println("Test creating new employee from existing employee: createEmployee(Employee e)");
//			String result2 = airlineservice.createEmployee(airlineservice.getEmployee("00012000"));
//			System.out.println("Result= " + result2);
			
			System.out.println(airlineservice.deleteEmployee("000120001"));
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
//		//***TEST CREATE CUSTOMER***
//		try {
//			System.out.println("Testing Customer Creation...");
//			System.out.println("Enter a first name:");
//			String firstName = br.readLine();
//			System.out.println("Enter a last name:");
//			String lastName = br.readLine();
//			System.out.println("Enter a nationality:");
//			String nationality = br.readLine();
//			
//			System.out.println("Test creating new customer from data: createCustomer(Customer c)");
//			String result = airlineservice.createCustomer(new Customer("","ProvidedPassword",firstName,lastName,"Address","City","State","Zip","Date","PassportNum",nationality));
//			System.out.println("Result= " + result);
//			System.out.println("Test creating new customer from existing customer: createCustomer(Customer c)");
//			String result2 = airlineservice.createCustomer(airlineservice.getCustomer("000020001"));
//			System.out.println("Result= " + result2);
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
		
		
		
		
//		Employee employee = airliness.getEmployee("000-12-0000");
//		String ssn = airliness.createEmployee(employee);
//		System.out.println("CreatedID=" + ssn);
//		employee = airliness.getEmployee("000-00-0006");
//		System.out.println("GetEmployee=" + employee.getFirstName() + " " + employee.getPersonID());
//		Employee tempemployee = new Employee("000-00-0006", "1280998e", "Changed", "EmployeeLastName", "Address", "City", "CA", "52732", "09-08-99", "EmployeeWorkDescription", "Changed", "04-02-2012");
//		Boolean update = airliness.updateEmployee(tempemployee);
//		employee = airliness.getEmployee("000-00-0006");
//		System.out.println("GetEmployeeAfterUpdate=" + employee.getFirstName() + " " + employee.getPersonID());
//		Employee[] employees = airliness.searchEmployees(new Employee());
//		for (int i = 0; i < employees.length; i++) {
//			System.out.println("Employee" + i + " = " + employees[i].getPersonID());
//		}
//  
//
//		
//		Journey selectedJourney = foundFlights[0];
//		selectedJourney.setCustomerID("000-02-0001");
//		selectedJourney.setPaymentOption("Credit");
//		String ticketNum = airliness.createJourney(foundFlights[0]);
//		System.out.println("Journey# =" + ticketNum);

//		Journey journey = new Journey("Delta", "ORD", "000-22-0000", "JFK", "08:00", "23674", "DL3333", 
//				"06:00", "", "", "Credit", "", "0", "0", "", "234.00");
//		String ticket = airliness.createJourney(journey);
//		Customer[] customers = airliness.getAllCustomersByFlightID("23674");
//		System.out.println("Number of Customers=" + customers.length);
//		System.out.println("Customer = " + customers[0].getPersonID());
//		//airliness.cancelJourney("2");
//		
//		//airliness.deleteCustomer("000-02-0003");
//	}
	
	
	
	}

}
